package com.bw.service

import android.widget.Switch
import androidx.recyclerview.widget.GridLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.constants.RoutePath
import com.bw.base.view.BaseFragment
import com.bw.service.adapter.ServiceCategoryAdapter
import com.bw.service.databinding.FragmentServiceBinding
import com.bw.service.model.ServiceData


@Route(path = RoutePath.PATH_SERVICE_FRAGMENT)
class ServiceFragment : BaseFragment<FragmentServiceBinding>() {

    private lateinit var sAdapter: ServiceCategoryAdapter

    override fun initView() {

        sAdapter = ServiceCategoryAdapter()
        sAdapter.data.clear()
        sAdapter.data.addAll(ServiceData.serviceCategoryList)
        binding.rv.adapter = sAdapter
        binding.rv.layoutManager = GridLayoutManager(context, 3)


    }

    override fun initData() {

        sAdapter.setOnItemClickListener { adapter, view, position ->
            val entity = sAdapter.data[position]


            when (entity.title) {
                "车位管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_PACK_CAR).navigation()
                }
                "车辆管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_CAR).navigation()
                }
                "巡检管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_POLLING).navigation()
                }
                "设备管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_DEVICE).navigation()
                }
                "访客管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_VISITOR).navigation()
                }
                "月卡会员" -> {
                    ARouter.getInstance().build(RoutePath.PATH_MEMBER).navigation()
                }
                "房源信息" -> {
                    ARouter.getInstance().build(RoutePath.PATH_HOUSE).navigation()
                }
                "维修管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_REPAIR).navigation()
                }
                "公告管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_ANNOUNCEMENT).navigation()
                }
                "考勤管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_ADD_ClOCK).navigation()
                }
                "物业报修" -> {
                    ARouter.getInstance().build(RoutePath.PATH_REPAIR).navigation()
                }
                "即时通讯" -> {
                    ARouter.getInstance().build(RoutePath.PATH_INSTANT).navigation()
                }
                "收银台" -> {
                    ARouter.getInstance().build(RoutePath.PATH_COUNTER).navigation()
                }
                "巡逻管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_PATROL).navigation()
                }
                "文化管理" -> {
                    ARouter.getInstance().build(RoutePath.PATH_CULTURE).navigation()
                }
                "我的申请" -> {
                    ARouter.getInstance().build(RoutePath.PATH_APPLY).navigation()
                }
                else -> {
                    ToastUtils.showShort(entity.title)
                }
            }

        }
    }

}